package com.cn.data.jpa.tool.spring.ioc.bean.annotation;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * spring的循环引用支持按照类型的方式注入，不支持构造方的方式注入
 */
public class BeanText {

    public static void main(String[] args) {

        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext();
        ac.setAllowCircularReferences(true);
        ac.register(AppConfig.class);
        ac.refresh();
        BeanFactory beanFactory = ac.getBeanFactory();
        IndexService indexService = beanFactory.getBean(IndexService.class);
        indexService.getNameService().init();
    }
}
